package com.ews.onlineexchange.dao;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

@Stateless
public class AgentServiceDao {	
	
	@PersistenceContext
	private EntityManager entityManager;
	
	private static final String FIND_BY_NAME_SQL = ""
			+ "	SELECT		count(agentService.id) "
			+ "	FROM		AgentService agentService"
			+ "	WHERE agentService.name = :name and delflag = '0'";
	public boolean findByName(String name) {
		Query query = entityManager.createQuery(FIND_BY_NAME_SQL);
		query.setParameter("name", name);
		long count = (long)query.getSingleResult();
		if(count > 0) return true;
		else return false;
	}
	
	
}
